<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="hexinyang">
<title>合同类别变更审核</title>
<script language="javascript" type="text/javascript"
	src="../script/print.js"></script>
<script language="javascript" src="../script/common.js"
	type="text/javascript"></script>
<script type="text/javascript">
		//页面加载方法	
		var qt = null;//数据表格对象
		var currentRequestId	
		
		
		function loadUserAuditTypes(){

			var items = DWR.syncCall("auditService.findAuditTypesByCategory",AuditCategory.CARDUSER)
			var item;
			for(var i=0;i<items.length;i++) {
				item = items[i];
				item.code =	item.id				// for select usage
				item.text = item.name
			}
			return items
		}
		
		function load(){		
			Eui.showNavigation();
			setPages(["listview","detview"]);
			Common.registerSpecialDict("user_audit_type",loadUserAuditTypes)
			searchForm.orgId.value = Common.cOrg().id;
			Common.initDict(searchForm.auditType,"user_audit_type" );
			Common.initDict(searchForm.status,AuditStatus.CATEGORY , "全 部");			//初始化性别(查询form)
			createTable();
		}
		
		
		function createTable(){
			var columns = []
		
			columns[18] = {title:"操作",width:"15",render:function(v,r){
				var str = "";
				if (r[7] == AuditStatus.OPEN){
					str = "<a href='#' onclick='showView("+r[8]+","+r[9]+","+r[10]+",true)'>审核</a>"
				}else
					str = "<a href='#' onclick='showView("+r[8]+","+r[9]+","+r[10]+")'>查看</a>"
				return str;
			},align:"center",order:false}
			qt = new QueryTable("verify_request", null, "datalist", columns,{
				paramFunc : function(){
					var params = Common.getValues(searchForm)
					params.title = searchForm.auditType.options[searchForm.auditType.selectedIndex].text;
					return params
				}
			});
			qt.showTable();
		}
		function showView(requestId,customerId,cardUserId,edit){
			switchPage("detview");
			currentRequestId = requestId
			DWR.call("auditService.getAuditProperties",requestId,function(result){
				html = ""
				$('auditProperties').innerHTML = html
			}
			);
			$("auditBtns").style.display=  edit?"":"none"
			CardMgnt.customer.show("customerview",customerId,CardMgnt.COMPANYALL,{isView:true,isCompany:true});
			CardMgnt.cardUser.show("carduserview",cardUserId,CardMgnt.COMPANYALL,{isView:true});
		}
		function approveRequest(){
			if (!currentRequestId)
			{
				showInformation("没有选择待审核的申请")
				return
			}
			if (!showQuestion("是否批准该申请？")) return;
			DWR.call("auditService.approveRequest",currentRequestId,function(){
				showInformation("该申请被批准");
				refresh();
			})
		}
		function refuseRequest(){
			if (!currentRequestId)
			{
				showInformation("没有选择待审核的申请")
				return
			}
			if (!showQuestion("是否拒绝该申请？")) return;
			DWR.call("auditService.refuseRequest",currentRequestId,function(){
				showInformation("该申请被拒绝");
				refresh();
			})
		}
		
		function refresh(){
			back();
			qt.showTable();
		}
		
		function back(){
			switchPage("listview");
			qt.showTable();
		}
		
	</script>
</head>
<body onload="load()">
<!--页面导航-->
<div class="nav">
<div id="nav">&nbsp;</div>
</div>
<div id="listview">
	<div class="searchForm">
		<form id="searchForm" name="searchForm">
			<input type="hidden" name="orgId">
			<table cellSpacing="0" cellPadding="4" width="100%" border="0"
				class="label5">
				<tr>
					<td><label>申请类别</label> <select name="auditType" onchange="createTable()"><option></option></select></td>
					<td><label>申请状态</label> <select name="status">
						<option></option>
					</select></td>
					<td>
					<button type="button" onclick="qt.showTable()">查 询</button>
					</td>
				</tr>
			</table>
		</form>
	</div>
	
	<div id="datalist"></div>
</div>
<div id="detview" style="display: none;">
	<div id="auditview" class="form">
		<div id="auditProperties"></div>
		<div id="auditBtns" align="center">
		<button onclick="approveRequest()">批准</button> <button onclick="refuseRequest()">拒绝</button>
		</div>
	</div>
	<div id="customerview" class="form">
	</div>
	<div id="carduserview" class="form">
	</div>
	<p>
		<button onclick="back()">返 回</button>
	</p>
</div>
</body>
</html>